package com.letoken.platform.admin.controller;

import com.letoken.platform.admin.service.AdminLeTokenService;
import com.letoken.platform.pub.annotation.auth.Permission;
import com.letoken.platform.pub.annotation.pub.Trim;
import com.letoken.platform.pub.req.PageData;
import com.letoken.platform.pub.res.ApiResponse;
import com.letoken.platform.repo.admin.req.user.*;
import com.letoken.platform.repo.admin.res.user.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author letokenlabs
 * @date 2022/11/23$
 */
@RestController
@RequestMapping("/letoken")
@Api(tags = "铸币发行相关接口")
public class AdminLeTokenController {

    @Autowired
    private AdminLeTokenService adminLeTokenService;

    @Permission(uri = "/letoken/issue/list",qx = "/mintIssue/releaseRecord")
    @Trim
    @PostMapping("/issue/list")
    @ApiOperation(value = "铸币发行-发行记录", notes = "铸币发行-发行记录")
    public ApiResponse<PageData<QueryIssueListRes>> queryIssueList(@RequestBody @Validated QueryIssueListReq req) {
        return ApiResponse.create(adminLeTokenService.queryIssueList(req));
    }

    @Permission(uri = "/letoken/circulation/list",qx = "/mintIssue/circulationRecord")
    @Trim
    @PostMapping("/circulation/list")
    @ApiOperation(value = "铸币发行-流通记录", notes = "铸币发行-流通记录")
    public ApiResponse<PageData<QueryCirculationListRes>> queryCirculationList(@RequestBody @Validated QueryCirculationListReq req) {
        return ApiResponse.create(adminLeTokenService.queryCirculationList(req));
    }

    @Permission(uri = "/letoken/issue/count",qx = "/letoken/issue/count")
    @GetMapping("/issue/count")
    @ApiOperation(value = "统计发行记录", notes = "统计发行记录")
    public ApiResponse<QueryIssueCountRes> queryIssueCount() {
        return ApiResponse.create(adminLeTokenService.queryIssueCount());
    }

    @Permission(uri = "/letoken/issue/LineChart",qx = "/letoken/issue/LineChart")
    @PostMapping("/issue/LineChart")
    @ApiOperation(value = "发行记录折线图", notes = "发行记录折线图")
    public ApiResponse<List<QueryLineChartRes>> queryIssueLineChart(@RequestBody @Validated QueryLineChartReq req) {
        return ApiResponse.create(adminLeTokenService.queryIssueLineChart(req));
    }

    @Permission(uri = "/letoken/circulation/count",qx = "/letoken/circulation/count")
    @GetMapping("/circulation/count")
    @ApiOperation(value = "统计流通记录", notes = "统计流通记录")
    public ApiResponse<QueryCirculationCountRes> queryCirculationCount() {
        return ApiResponse.create(adminLeTokenService.queryCirculationCount());
    }


    @Permission(uri = "/letoken/circulation/accelerate/list",qx = "/mintIssue/accelerate")
    @Trim
    @PostMapping("/circulation/accelerate/list")
    @ApiOperation(value = "铸币发行-加速流通记录", notes = "铸币发行-加速流通记录")
    public ApiResponse<PageData<QueryAccelerateListRes>> queryAccelerateList(@RequestBody @Validated QueryAccelerateListReq req) {
        return ApiResponse.create(adminLeTokenService.queryAccelerateList(req));
    }

    @Permission(uri = "/letoken/circulation/accelerate/count",qx = "/mallIssueRecordController/accelerate")
    @GetMapping("/circulation/accelerate/count")
    @ApiOperation(value = "统计加速流通记录", notes = "统计加速流通记录")
    public ApiResponse<QueryAccelerateCountRes> queryAccelerateCount() {
        return ApiResponse.create(adminLeTokenService.queryAccelerateCount());
    }

    @Permission(uri = "/letoken/circulation/LineChart",qx = "/letoken/circulation/LineChart")
    @PostMapping("/circulation/LineChart")
    @ApiOperation(value = "流通记录折线图", notes = "流通记录折线图")
    public ApiResponse<List<QueryLineChartRes>> queryCirculationLineChart(@RequestBody @Validated QueryLineChartReq req) {
        return ApiResponse.create(adminLeTokenService.queryCirculationLineChart(req));
    }

}
